package com.kongchengji.spider.util;

import com.kongchengji.spider.picServer.UpdatePicServer;
import com.kongchengji.spider.station.dao.OnlyPicIdentifyingDao;
import com.kongchengji.spider.station.domain.PictureModelDO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

/**
 * 接受数据接口工具
 */
public class AccessInterfaceUtil {
    static OnlyPicIdentifyingDao onlyPicIdentifyingDao = SpringContextUtil.getBean(OnlyPicIdentifyingDao.class);
    static UpdatePicServer updatePicServer = SpringContextUtil.getBean(UpdatePicServer.class);
    static Logger logger = LoggerFactory.getLogger(AccessInterfaceUtil.class);
    public static void accessInterface(PictureModelDO pictureModelDO) {
        if (onlyPicIdentifyingDao.selectOne(pictureModelDO.getThumbnailUrl()) == 0) {
            try {
                updatePicServer.updatePic(pictureModelDO);
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            logger.error("已存在该图集");

        }
    }
}
